{% extends 'generic/object.html' %}
{% load helpers %}
{% load plugins %}
{% load render_table from django_tables2 %}
{% load i18n %}

{% block content %}
  <div class="row">
    <div class="col col-12 col-md-6">
      <div class="card">
        <h2 class="card-header">{% trans "Tag" %}</h2>
        <table class="table table-hover attr-table">
          <tr>
            <th scope="row">{% trans "Name" %}</th>
            <td>
              {{ object.name }}
            </td>
          </tr>
          <tr>
            <th scope="row">{% trans "Description" %}</th>
            <td>
                {{ object.description|placeholder }}
            </td>
          </tr>
          <tr>
            <th scope="row">{% trans "Color" %}</th>
            <td>
                <span class="color-label" style="background-color: #{{ object.color }}">&nbsp;</span>
            </td>
          </tr>
          <tr>
            <th scope="row">{% trans "Weight" %}</th>
            <td>{{ object.weight }}</td>
          </tr>
          <tr>
            <th scope="row">{% trans "Tagged Items" %}</th>
            <td>
                {{ taggeditem_table.rows|length }}
            </td>
          </tr>
        </table>
      </div>
      {% plugin_left_page object %}
    </div>
    <div class="col col-12 col-md-6">
      <div class="card">
        <h2 class="card-header">{% trans "Allowed Object Types" %}</h2>
        <table class="table table-hover attr-table">
          {% for ct in object.object_types.all %}
            <tr>
              <td>{{ ct }}</td>
            </tr>
          {% empty %}
            <tr>
              <td class="text-muted">{% trans "Any" %}</td>
            </tr>
          {% endfor %}
        </table>
      </div>
      <div class="card">
        <h2 class="card-header">{% trans "Tagged Item Types" %}</h2>
        <ul class="list-group list-group-flush" role="presentation">
          {% for object_type in object_types %}
            {% action_url object_type.content_type.model_class 'list' as list_url %}
            {% if list_url %}
              <a href="{{ list_url }}?tag={{ object.slug }}" class="list-group-item list-group-item-action d-flex justify-content-between">
                {{ object_type.content_type.name|bettertitle }}
                <span class="badge text-bg-primary rounded-pill">{{ object_type.item_count }}</span>
              </a>
            {% else %}
              <li class="list-group-item list-group-item-action d-flex justify-content-between">
                {{ object_type.content_type.name|bettertitle }}
                <span class="badge text-bg-primary rounded-pill">{{ object_type.item_count }}</span>
              </li>
            {% endif %}
          {% endfor %}
        </ul>
      </div>
      {% plugin_right_page object %}
    </div>
  </div>
  <div class="row">
    <div class="col col-md-12">
      <div class="card">
        <h2 class="card-header">{% trans "Tagged Objects" %}</h2>
        <div class="table-responsive">
          {% render_table taggeditem_table 'inc/table.html' %}
          {% include 'inc/paginator.html' with paginator=taggeditem_table.paginator page=taggeditem_table.page %}
        </div>
      </div>
      {% plugin_full_width_page object %}
    </div>
  </div>
{% endblock %}
